let drawRound = (num1 = 0, num2 = 0) => { // 圆形图表配置绘制参数
	return {
		color: ['#75a8ef', '#FFDB5C'],
		tooltip: {},
		series: [{
			type: 'pie',
			roseType: 'angle',
			radius: '65%',
			data: [{
				value: num1,
				name: '已完成'
			}, {
				value: num2,
				name: '未完成'
			}], 
			itemStyle: {
				// 阴影的大小
				shadowBlur: 30,
				shadowColor: 'rgba(0, 0, 0, 0.2)'
			}
		}]
	}
}

let drawBar = (time, accomplish, unfinished) => { // 封装条形图方法
	return {
		color: ['#75a8ef', '#FFDB5C'],
		legend: {
			data: ['已完成', '未完成']
		},
		tooltip: {},
		grid: {
			x: 35,
			x2: 10,
			y: 30,
			y2: 25
		},
		calculable: false,
		xAxis: [{
			type: 'category',
			data: time
		}],
		yAxis: [{
			type: 'value',
			splitArea: {
				show: true
			}
		}],
		series: [{
			name: '已完成',
			type: 'bar',
			data: accomplish
		}, {
			name: '未完成',
			type: 'bar',
			data: unfinished
		}]
	}

}


let listForEach = (list, type) => {
	var a = [],
		b = [],
		c = [],
		name
	list.forEach((item, index)=> {
		name = item.timeUnit + (type == 1 ? '周' : type == 2 ? '月' : '年')
		a.push(name);
		b.push(item.achieveTaskPercentage);
		c.push(item.notAchieveTaskPercentage);
	})
	
	return drawBar(a,b,c)
}

module.exports = {
	drawRound: drawRound,
	drawBar: drawBar,
	listForEach: listForEach
}
